-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add overlap functionality to Timex.Interval #493
base: main
Are you sure you want to change the base?
Conversation
2 similar comments
8764c92
to
1b5a171
Compare
lib/interval/interval.ex
Outdated
@@ -382,6 +382,71 @@ defmodule Timex.Interval do | |||
def max(%__MODULE__{until: until, right_open: false}), do: until | |||
def max(%__MODULE__{until: until}), do: Timex.shift(until, microseconds: -1) | |||
|
|||
@doc """ | |||
Returns an Interval representing the intersection between two intervals. | |||
If the intervals do not overlap, reutrn {:error, :no_overlap_interval}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misspelling reutrn
lib/interval/interval.ex
Outdated
|
||
@doc """ | ||
When calculating overlap, if two intervals share a `from` (or `until`), the overlap | ||
interval should have a bound matching the "inner" interval (eg: if either inteval has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spelling: inteval
* Find the overlap Interval between two intervals. * Return {:error, :no_overlap_interval} if intervals do not overlap, (including overlapping at one instant)
1b5a171
to
e10c8fa
Compare
Returns an Interval representing the intersection between two intervals. | ||
If the intervals do not overlap, return {:error, :no_overlap_interval}. | ||
If the intervals overlap at a single instant (regardless of open/closed | ||
bounds), also return {:error, :no_overlap_interval} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it should return 0
in the case of no overlap rather than an error? Two intervals not overlapping doesn't seem like an error to me.
Summary of changes
do not overlap, (including overlapping at one instant)
Checklist